home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / lib / mntlib44.zoo / mntlib / purec / unixname / unixname.s next >
Text File  |  1994-01-16  |  7KB  |  227 lines

  1. ;{{{}}}
  2. ;{{{  about this file
  3. ; Author: Michael Schwingen
  4. ;         Kranichstraße 10
  5. ;         5042 Erftstadt
  6. ; purpose:
  7. ; Unixname installes itself resident in the GEMDOS trap vector and converts
  8. ; all '/'s in filenames to TOS-like '\'.
  9. ; Assembler: DevpacST 2.0
  10. ;}}}
  11. ;{{{  List of GEMDOS-functions and address of filename on stack
  12. ; 57 (Dcreate)  : 8(SP)
  13. ; 58 (Ddelete)  : 8(SP)
  14. ; 59 (Dsetpath) : 8(SP)
  15. ; 60 (Fcreate)  : 8(SP)
  16. ; 61 (Fopen)    : 8(SP)
  17. ; 65 (Fdelete)  : 8(SP)
  18. ; 67 (Fattrib)  : 8(SP)
  19. ; 75 (Pexec)    : 10(SP) - 8(SP) = mode, changes only if 0/3 !
  20. ; 78 (Fsfirst)  : 8(SP)
  21. ; 86 (Frename)  : 10(SP),14(SP)
  22. ;}}}
  23.  
  24.               opt o+
  25.  
  26. start:        bra     init
  27.  
  28. ;{{{  new trap#1 handler
  29.               DC.B "XBRAUn*x"
  30. oldvec:       DC.L 0
  31. new_vec:      move.w  (sp),d0         ; get SR
  32.               lea     6(sp),a0
  33.               btst    #$0D,d0         ; SUPER-mode ?
  34.               bne.s   .new2           ; yes
  35.               move    usp,a0          ; no, parameters are on userstack
  36. .new2:        move.w  (a0),d0         ; get GEMDOS Opcode
  37.               cmp.w   #57,d0          ; Dcreate() ?
  38.               beq     func_type1
  39.               cmp.w   #58,d0          ; Ddelete() ?
  40.               beq     func_type1
  41.               cmp.w   #59,d0          ; Dsetpath() ?
  42.               beq     func_type1
  43.               cmp.w   #60,d0          ; Fcreate() ?
  44.               beq     func_type1
  45.               cmp.w   #61,d0          ; Fopen() ?
  46.               beq     func_type1
  47.               cmp.w   #65,d0          ; Fdelete() ?
  48.               beq     func_type1
  49.               cmp.w   #67,d0          ; Fattrib() ?
  50.               beq     func_type1
  51.               cmp.w   #75,d0          ; Pexec() ?
  52.               beq     func_pexec
  53.               cmp.w   #78,d0          ; Fsfirst() ?
  54.               beq     func_type1
  55.               cmp.w   #86,d0          ; Frename() ?
  56.               beq     func_frename
  57. old_vec:      movea.l oldvec,a0
  58.               jmp     (a0)
  59. func_type1:   movea.l 2(a0),a0        ; ptr to filename
  60. func1_1:      bsr     convert_name
  61.               bra.s   old_vec
  62. func_pexec:   move.w  2(a0),d0        ; mode: 0/3 = filename at 4(a0)
  63.               cmp.w   #0,d0
  64.               beq.s   .pexec2
  65.               cmp.w   #3,d0
  66.               bne.s   old_vec
  67. .pexec2:      movea.l 4(a0),a0
  68.               bra.s   func1_1
  69. func_frename: move.l  a0,-(sp)
  70.               movea.l 8(a0),a0
  71.               bsr     convert_name
  72.               movea.l (sp)+,a0
  73.               bra.s   func_pexec
  74. ;}}}
  75. ;{{{  convert_name: convert '/' -> '\'  at (a0)+
  76. convert_name:
  77.               move.b  (a0),d0
  78.               beq     .convend
  79.               cmp.b   #"/",d0
  80.               bne     .convnext
  81.               move.b  #"\",(a0)
  82. .convnext:    addq.l  #1,a0
  83.               bra.s   convert_name
  84. .convend:     rts
  85. ;}}}
  86.  
  87. res_len       EQU *-start
  88. ; everything after this point does not stay resident in memory
  89.  
  90. ;{{{  install resident part
  91. init:         pea     new_vec(pc)
  92.               move.l  #$050021,-(sp)  ; Setexc(33,...)
  93.               trap    #13
  94.               addq.l  #8,sp
  95.               move.l  d0,oldvec
  96.  
  97.               lea     inst_txt(pc),a0
  98.               bsr     Cconws
  99.  
  100.               clr.w   -(sp)           ; Ret.-Code
  101.               move.l  #256+res_len,-(sp)
  102.               move.w  #49,-(sp)       ; Ptermres()
  103.               trap    #1
  104. ;}}}
  105. ;{{{  Cconws: print text
  106. Cconws:       move.l  a0,-(sp)
  107.               move.w  #9,-(sp)
  108.               trap    #1              ; Cconws
  109.               addq.l  #6,sp
  110.               rts
  111. ;}}}
  112.  
  113. inst_txt:     DC.B 13,10,"Un*xName V1.0 © 1991 by Michael Schwingen installed.",13,10,0
  114. ;{{{}}}
  115. ;{{{  about this file
  116. ; Author: Michael Schwingen
  117. ;         Kranichstraße 10
  118. ;         5042 Erftstadt
  119. ; purpose:
  120. ; Unixname installes itself resident in the GEMDOS trap vector and converts
  121. ; all '/'s in filenames to TOS-like '\'.
  122. ; Assembler: DevpacST 2.0
  123. ;}}}
  124. ;{{{  List of GEMDOS-functions and address of filename on stack
  125. ; 57 (Dcreate)  : 8(SP)
  126. ; 58 (Ddelete)  : 8(SP)
  127. ; 59 (Dsetpath) : 8(SP)
  128. ; 60 (Fcreate)  : 8(SP)
  129. ; 61 (Fopen)    : 8(SP)
  130. ; 65 (Fdelete)  : 8(SP)
  131. ; 67 (Fattrib)  : 8(SP)
  132. ; 75 (Pexec)    : 10(SP) - 8(SP) = mode, changes only if 0/3 !
  133. ; 78 (Fsfirst)  : 8(SP)
  134. ; 86 (Frename)  : 10(SP),14(SP)
  135. ;}}}
  136.  
  137.               opt o+
  138.  
  139. start:        bra     init
  140.  
  141. ;{{{  new trap#1 handler
  142.               DC.B "XBRAUn*x"
  143. oldvec:       DC.L 0
  144. new_vec:      move.w  (sp),d0         ; get SR
  145.               lea     6(sp),a0
  146.               btst    #$0D,d0         ; SUPER-mode ?
  147.               bne.s   .new2           ; yes
  148.               move    usp,a0          ; no, parameters are on userstack
  149. .new2:        move.w  (a0),d0         ; get GEMDOS Opcode
  150.               cmp.w   #57,d0          ; Dcreate() ?
  151.               beq     func_type1
  152.               cmp.w   #58,d0          ; Ddelete() ?
  153.               beq     func_type1
  154.               cmp.w   #59,d0          ; Dsetpath() ?
  155.               beq     func_type1
  156.               cmp.w   #60,d0          ; Fcreate() ?
  157.               beq     func_type1
  158.               cmp.w   #61,d0          ; Fopen() ?
  159.               beq     func_type1
  160.               cmp.w   #65,d0          ; Fdelete() ?
  161.               beq     func_type1
  162.               cmp.w   #67,d0          ; Fattrib() ?
  163.               beq     func_type1
  164.               cmp.w   #75,d0          ; Pexec() ?
  165.               beq     func_pexec
  166.               cmp.w   #78,d0          ; Fsfirst() ?
  167.               beq     func_type1
  168.               cmp.w   #86,d0          ; Frename() ?
  169.               beq     func_frename
  170. old_vec:      movea.l oldvec,a0
  171.               jmp     (a0)
  172. func_type1:   movea.l 2(a0),a0        ; ptr to filename
  173. func1_1:      bsr     convert_name
  174.               bra.s   old_vec
  175. func_pexec:   move.w  2(a0),d0        ; mode: 0/3 = filename at 4(a0)
  176.               cmp.w   #0,d0
  177.               beq.s   .pexec2
  178.               cmp.w   #3,d0
  179.               bne.s   old_vec
  180. .pexec2:      movea.l 4(a0),a0
  181.               bra.s   func1_1
  182. func_frename: move.l  a0,-(sp)
  183.               movea.l 8(a0),a0
  184.               bsr     convert_name
  185.               movea.l (sp)+,a0
  186.               bra.s   func_pexec
  187. ;}}}
  188. ;{{{  convert_name: convert '/' -> '\'  at (a0)+
  189. convert_name:
  190.               move.b  (a0),d0
  191.               beq     .convend
  192.               cmp.b   #"/",d0
  193.               bne     .convnext
  194.               move.b  #"\",(a0)
  195. .convnext:    addq.l  #1,a0
  196.               bra.s   convert_name
  197. .convend:     rts
  198. ;}}}
  199.  
  200. res_len       EQU *-start
  201. ; everything after this point does not stay resident in memory
  202.  
  203. ;{{{  install resident part
  204. init:         pea     new_vec(pc)
  205.               move.l  #$050021,-(sp)  ; Setexc(33,...)
  206.               trap    #13
  207.               addq.l  #8,sp
  208.               move.l  d0,oldvec
  209.  
  210.               lea     inst_txt(pc),a0
  211.               bsr     Cconws
  212.  
  213.               clr.w   -(sp)           ; Ret.-Code
  214.               move.l  #256+res_len,-(sp)
  215.               move.w  #49,-(sp)       ; Ptermres()
  216.               trap    #1
  217. ;}}}
  218. ;{{{  Cconws: print text
  219. Cconws:       move.l  a0,-(sp)
  220.               move.w  #9,-(sp)
  221.               trap    #1              ; Cconws
  222.               addq.l  #6,sp
  223.               rts
  224. ;}}}
  225.  
  226. inst_txt:     DC.B 13,10,"Un*xName V1.0 © 1991 by Michael Schwingen installed.",13,10,0
  227.